package CtrLayer;

import java.util.ArrayList;

import ModelLayer.StaffMemberCollection;

/**
 * Write a description of class StaffCtr here.
 * 
 * @author (your name)
 * @version (a version number or a date)
 */
public class StaffCtr
{
	/**
	 * Constructor for objects of class StaffCtr
	 */
	public StaffCtr()
	{

	}

	public boolean save_data()
	{
		return StaffMemberCollection.save_data();
	}

	public boolean add_account(String name, String phone_nr, String address,
			String postal_code, String city, String login, String password,
			int salary, boolean is_manager)
	{
		return StaffMemberCollection.add_staff_member(name, phone_nr, address,
				postal_code, city, login, password, salary, is_manager);
	}

	public String print_employee(String id)
	{
		return StaffMemberCollection.print_employee(id);
	}

	public boolean delete_account(String id)
	{
		return StaffMemberCollection.delete_account(id);
	}

	public String print_all_employees()
	{
		return StaffMemberCollection.print_all_employees();
	}
	
	public String[] get_order_ids(String id)
	{
		return StaffMemberCollection.get_order_ids(id);
	}
	
	public String[] get_account_fields(String id)
	{
		String[] fields = new String[10];
		Object[] data = StaffMemberCollection.get_account_fields(id);
		for(int i = 0; i < 7; i++)
		{
			fields[i] = (String) data[i];
		}
		fields[7] = String.valueOf(data[7]);
		fields[8] = (String) data[8];
		fields[9] = String.valueOf(data[9]);
		return fields;
	}

	/*********************************************************** EDITING FUNCTIONS ***************************************************************/
	public void edit_name(String id, String name)
	{
		StaffMemberCollection.edit_name(id, name);
	}

	public void edit_phone_nr(String id, String phone_nr)
	{
		StaffMemberCollection.edit_phone_nr(id, phone_nr);
	}

	public void edit_address(String id, String address, String postal_code,
			String city)
	{
		StaffMemberCollection.edit_address(id, address, postal_code, city);
	}

	public void edit_salary(String id, int salary)
	{
		StaffMemberCollection.edit_salary(id, salary);
	}

	public void edit_login(String id, String login)
	{
		StaffMemberCollection.edit_login(id, login);
	}

	public void edit_password(String id, String password)
	{
		StaffMemberCollection.edit_password(id, password);
	}

	public void edit_is_manager(String id, boolean is_manager)
	{
		StaffMemberCollection.edit_is_manager(id, is_manager);
	}

	public boolean is_login_used(String login)
	{
		return StaffMemberCollection.is_login_used(login);
	}

	public boolean is_manager(String id)
	{
		return StaffMemberCollection.is_manager(id);
	}

	public boolean is_such_id(String id)
	{
		return StaffMemberCollection.is_such_id(id);
	}
	
	public Object[][] give_all_accounts(boolean is_owner)
	{
		if (is_owner)
		{
			return StaffMemberCollection.give_all_accounts();
		}
		else
		{
			return StaffMemberCollection.give_employee_accounts();
		}
	}
	
	public Object[] give_single_account(String id, boolean is_owner)
	{
		return StaffMemberCollection.give_single_account(id, is_owner);
	}
	
	public Object[][] give_accounts_via_name(String name, boolean is_owner)
	{
		ArrayList<Object[]> accounts = StaffMemberCollection.give_accounts_via_name(name, is_owner);
		Object[][] data = new Object[accounts.size()][4];
		int i = 0;
		for (Object[] account : accounts)
		{
			data[i] = account;
			i++;
		}
		return data;
	}
	
	public String get_next_account_id()
	{
		return StaffMemberCollection.get_next_account_id();
	}
	
	public String[] give_string_array(String id)
	{
		return StaffMemberCollection.give_string_array(id);
	}
			

}
